﻿using System;

namespace CyberConnect.Insteon
{
    /// <summary>
    /// Indicates the type of SET Button event that occured.
    /// </summary>
    public enum ButtonReport
    {
        /// <summary>
        /// No button press.
        /// </summary>
        None = 0x00,

        /// <summary>
        /// SET button was pressed.
        /// </summary>
        SetPressed = 0x02,

        /// <summary>
        /// SET button was held for 3 seconds.
        /// </summary>
        SetHeld = 0x03,

        /// <summary>
        /// SET button was released after being held for 3 seconds.
        /// </summary>
        SetHeldRelease = 0x04,

        /// <summary>
        /// Button2 was pressed.
        /// </summary>
        Button2Pressed = 0x12,

        /// <summary>
        /// Button2 was held for 3 seconds.
        /// </summary>
        Button2Held = 0x13,

        /// <summary>
        /// Button2 was released after being held for 3 seconds.
        /// </summary>
        Button2HeldRelease = 0x14,

        /// <summary>
        /// Button3 was pressed.
        /// </summary>
        Button3Pressed = 0x22,

        /// <summary>
        /// Button3 was held for 3 seconds.
        /// </summary>
        Button3Held = 0x23,

        /// <summary>
        /// Button3 was released after being held for 3 seconds.
        /// </summary>
        Button3HeldRelease = 0x24
    }

    /// <summary>
    /// Handles ButtonReport events used by the INSTEON PLM.
    /// </summary>
    /// <param name="sender">The object invoking the event.</param>
    /// <param name="e">The event arguments containing button press information.</param>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1003:UseGenericEventHandlerInstances")]
    public delegate void ButtonReportEventHandler(object sender, ButtonReportEventArgs e);

    /// <summary>
    /// Event Arguments used for an ButtonReport
    /// </summary>
    [System.ComponentModel.ImmutableObject(true)]
    public class ButtonReportEventArgs : EventArgs
    {
        private readonly ButtonReport _Report;

        /// <summary>
        /// The ButtonReport of which the event is referring.
        /// </summary>
        public ButtonReport Report { get { return _Report; } }

        /// <summary>
        /// Initializes ButtonReportEventArgs with a ButtonReport as the report.
        /// </summary>
        /// <param name="report">ButtonReport to which the event is referring.</param>
        public ButtonReportEventArgs(ButtonReport report)
        {
            this._Report = report;
        }
    }
}